import {NzMessageService, NzTreeNode} from 'ng-zorro-antd';
import {Component, OnInit, ChangeDetectorRef, Injector, ViewChild} from '@angular/core';
import {_HttpClient, SettingsService, TitleService} from '@delon/theme';
import { LoginService } from '../../service/login.service';
import { catchError } from 'rxjs/operators';
import { of } from 'rxjs/observable/of';

import {ReuseTabService, SimpleTableColumn, SimpleTableComponent} from '@delon/abc';
import { getTimeDistance, yuan } from '@delon/util';
import {ProductService} from "../../service/prod/product.service";
import {fkService} from "../../service/fk/fk.service";
import {Constant} from "@core/constant";
import {CommService} from "../../service/comm/comm.service";
import {format} from "date-fns";
import {poListService} from "../../service/poList/poList.service";
import {Router} from "@angular/router";

@Component({
    selector: 'pos-home',
    templateUrl: './home.component.html',
    styleUrls: ['./home.component.less']
})
export class HomeComponent implements OnInit {
  today;
  dh1=8000123456;
  sh1=1800
  zt1="已下单";
  dh2=8000123457;
  sh2=1800
  zt2="已下单";
  dh3=8000123458;
  sh3=1800
  zt3="已下单";
  dh4=8000123459;
  sh4=1800
  zt4="已下单";
  dh5=8000123410;
  sh5=1800
  zt5="已下单";
  dh6=8000123412;
  sh6=1800
  zt6="已下单";
  inter;

  bilist11title='订单详情';


  tuisong='欢迎使用雅瑞供应商管理系统。';
  loanNalanceWeek='12'; //
  loanNalanceWeekUp='down'; //
  loanNalanceData='12'; //
  loanNalanceDataUp='up'; //



  bihome11="0";
  bihome12="0";
  bihome13="0";
  bihome14="0";

  @ViewChild('st') st: SimpleTableComponent;
  // 表格数据url
  url = this.poListService.list();
  // region end



  data: any = {};
  loading = true;


  columns: SimpleTableColumn[] = [
    // { title: '', index: 'key', type: 'checkbox' },


    // {
    //   title: '操作',
    //   buttons: [
    //     {
    //       text: '发货详情',
    //       type: 'link',
    //       click: (record: any) => this.router.navigate(['/poList/poList/fh/'+record.ebeln])
    //     },
    //     {
    //       text: '收货详情',
    //       type: 'link',
    //       click: (record: any) => this.router.navigate(['/poList/poList/sh/'+record.ebeln])
    //     },
    //     {
    //       text: '批次详情',
    //       type: 'link',
    //       click: (record: any) => this.router.navigate(['/poList/poList/batch/'+record.ebeln])
    //     }
    //   ]
    // } ,
    { title: '单据类型', index: 'zzph' },
    { title: '库存类型', index: 'zwxdkc' },
    { title: '是否备料', index: 'zsfbl' },
    // { title: '采购组织', index: 'ekorg' },
    // { title: '采购组', index: 'ejgrp' },
    // { title: '采购订单类型', index: 'bsart' },
    { title: '凭证日期', index: 'bedat' },
    { title: '供应商', index: 'lifnr' },
    { title: '名称', index: 'name1' },
    { title: '订单编号', index: 'ebeln' },
    { title: '订单项目', index: 'ebelp' },
    { title: '物料编号', index: 'matnr' },
    { title: '物料描述', index: 'maktx' },
    { title: '单位', index: 'meins' },
    // { title: '供应商物料号', index: 'idnlf' },
    // { title: '物料组', index: 'matkl' },
    // { title: '净价', index: 'netpr' },
    // { title: '税码', index: 'nwskz' },
    // { title: '付款条件', index: 'zterm' },
    // { title: '备注', index: 'ihrez' },
    { title: '订单数量', index: 'menge' },
    { title: '在途数量', index: 'menge1' },
    { title: '已发货', index: 'menge2' },
    { title: '未清数量', index: 'menge3' }
  ];
  ps = 10;
  // 搜索表单
  q: any = {
    lifnr:"",

    name1: '',
    ebeln: '',
    matnr:''
  };
  constructor(
    private comm: CommService,
    public msg: NzMessageService,
    private poListService: poListService,
    private router: Router,

    public setting: SettingsService,
  ) {}


      ngOnInit() {

        const beginDay = new Date().getTime();

        this.inter = setInterval(() => {
          this.today = new Date();// 或者this.today = new Date();
          // this.tuisong=this.today;
          // this.getgetbihome("bihome11");
          // this.getgetbihome("bihome12");
          // this.getgetbihome("bihome13");
          // this.getgetbihome("bihome14");
          // this.getgetbilist("bilist11");
          // this.getgetbilist("bilist12");
          // this.getgetbilist("bilist13");
        }, 1000);

      }

  ngOnDestroy() {
    if (this.inter) {
      clearInterval(this.inter);
    }
  }
getgetbihome(bitype){
  this.comm.getbi(bitype).pipe(
    catchError(err => {
      return of(err);
    })
  ).subscribe(data => {
      if(bitype=="bihome11"){
        this.bihome11=data.data[0].fxjx1;
      }
      if(bitype=="bihome12"){
        this.bihome12=data.data[0].fxjx1;
      }
      if(bitype=="bihome13"){
        this.bihome13=data.data[0].fxjx1;
      }
      if(bitype=="bihome14"){
        this.bihome14=data.data[0].fxjx1;
      }
  })

}
  checkboxChange(list: any[]) {
  }


  _activeTab = 0;
  _tabChange(value: any) {}
}
